package cn.gwm.flink.streaming.dws.reservecharge.enums;

import cn.gwm.flink.streaming.dwm.charge.model.ChargeStateEnum;
import lombok.Getter;

/**
 * @author Liu.Nanfang
 * @date 2023/2/15 15:18
 * @description 充电地点类型
 */
@Getter
public enum ChargeBusiStatusEnum {

    /**
     * 1 待充电 10延迟充电
     */
    WAIT("1", "待充电"),
    UNDERWAY("2", "正在充电"),
    /**
     * 充满电且插抢时间不为空 判断为充电结束 3: 充满电 6 充电结束
     */
    END("3", "充满电"),
    /**
     * 状态合并 4: 充不进去 5: 充电中断
     */
    FAULT("4", "充电中断"),
    /**
     * 状态合并 9: 连接出错 8: 逻辑断开 7: 发生故障
     */

    SUSPEND("5", "充电故障"),

    PREHEAT("6", "充电预热"),

    CHARGING_HEATING("7", "充电加热"),

    OTHER("11", "其它"),
    ;

    /**
     * 显示 编码
     */
    private String code;
    /**
     * 描述
     */
    private String desc;

    ChargeBusiStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据类型的名称，返回类型的枚举实例。
     *
     * @param key 类型名称
     */
    public static ChargeStateEnum fromKey(String key) {
        for (ChargeStateEnum type : ChargeStateEnum.values()) {
            if (type.getCode().equals(key)) {
                return type;
            }
        }
        return null;
    }
}
